package top.zsyle.movie.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import top.zsyle.movie.domain.UserMovie;
import top.zsyle.movie.dto.GetMiddleDto;
import top.zsyle.movie.mapper.UserMovieMapper;
import top.zsyle.movie.result.JsonResult;
import top.zsyle.movie.service.IUserMovieService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhongshiyi
 * @since 2023-01-02
 */
@Service
public class UserMovieServiceImpl extends ServiceImpl<UserMovieMapper, UserMovie> implements IUserMovieService {

    @Override
    public UserMovie getMiddleByUserIdAndMovieId(GetMiddleDto dto) {
        Long userId = dto.getUserId();
        Long movieTicketId = dto.getMovieTicketId();
        Wrapper<UserMovie> wrapper = new EntityWrapper<>();
        Wrapper<UserMovie> eq = wrapper.eq("user_id", userId).and().eq("movie_ticket_id", movieTicketId);
        return selectOne(eq);
    }
}
